cd ${work}5_reg_analysis

local ylist		"log_vrd_exp_exsmall log_value"
local felist	`" "P2DY P4D P4Y" "'

use temp\regsample_pdt, clear

gen x_ols = treated_sum_2
lab var x_ols "OLS"
gen x_iv = treated_sum_2
lab var x_iv "2SLS"

gen z=tdcinitiative_sum_2

eststo clear
local mtitles
local n=1

foreach y of local ylist {
local nfe=1	
foreach fe of local felist {
	
	eststo est1: reghdfe `y' x_ols , a(`fe') vce(robust) nosamp
	
	eststo est2: ivreghdfe `y' (x_iv=z) , a(`fe') robust
	local N = e(N)
	local F = e(widstat)
	
	eststo stacked_`n' : appendmodels est1 est2
	eststo drop est*
	qui estadd scalar N `N'
	qui estadd scalar F `F'
	qui estadd local FE `fe'
	local mtitles `mtitles' "`:var lab `y''"
		
	local ++n
	local ++nfe
	
}	
}
	
esttab using output\table_a11.tex , replace booktabs se label ///
	title("Effect of Export Support on Aggregate Trade") star(* 0.1 ** 0.05 *** 0.01) mtitles(`mtitles') keep(x_*) ///
	stats(N F FE , labels("Observations" "IV F-stat" "Fixed Effects") fmt(%10.0fc %10.0fc ""))
	